package com.ccl.iot;
public class IOTAuthFilter {
	public final static IOTAuthFilter KOWNER = new IOTAuthFilter(IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_OWNER);
	public final static IOTAuthFilter KAUTHED = new IOTAuthFilter(IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_READ,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_WRITE,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_FULL);
	public final static IOTAuthFilter KUNAUTH = new IOTAuthFilter(IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_NONE,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_WAITTING,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_REJECT,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_QUIT,
			IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_UNKNOWN);
	public final static IOTAuthFilter KALL = new IOTAuthFilter(IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_NONE,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_OWNER,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_READ,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_WRITE,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_FULL,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_WAITTING,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_REJECT,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_QUIT,
																										IOTNetAPIEnum.EAUTH_STATE.EAUTH_STATE_UNKNOWN);
	
	private int iAuths[] = null;
	
	IOTAuthFilter(int ... aAuths){
		if (aAuths != null && aAuths.length > 0){
			iAuths = aAuths;
		}
	}
	
	public int[] getAuths(){
		return iAuths;
	}
	
	public boolean isRightAuth(int aAuth){
		if (iAuths != null){
			for (int i = 0; i < iAuths.length; i++){
				if (iAuths[i] == aAuth){
					return true;
				}
			}
		}
		
		return false;
	}
}
